package com.company.dcm.aspect;

import com.company.dcm.exception.CustomizedException;
import com.company.dcm.utils.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class RealTimeAspect {
    @Pointcut("execution(* com.company.dcm.controller.RealTimeController.getR_DeviceInfo(..))")
    public void getR_DeviceInfoPointCut(){
    }

    @Before("getR_DeviceInfoPointCut()")
    public void getR_DeviceInfoBefore(JoinPoint joinPoint) {
        Object[] args = joinPoint.getArgs();
        String deviceCode = (String) args[0];
        if(StringUtils.isNullOrEmpty(deviceCode)){
            throw new CustomizedException("机台设备编号不能为空");
        }
    }
}
